package demo06;

// 游戏中的英雄角色类
public class Hero {
    private String name; // 英雄名
    private int age; // 英雄年龄
    private Weapon weapon; // 武器

    public void attack() { // weapon是个对象，需要调用其方法获得里面想要的值
        System.out.println("今年" + age + "岁的" + name + "正在使用" + weapon.getCode() + "攻击敌人...");
    }

    // GETTER/SETTER、无参/全参构造...
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Weapon getWeapon() {
        return weapon;
    }

    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }

    public Hero() {
    }

    public Hero(String name, int age, Weapon weapon) {
        this.name = name;
        this.age = age;
        this.weapon = weapon;
    }
}
